var Table = {
    Select: function( selectbox, server, db ) {
        var table = selectbox_value( selectbox );
        
        CreateTable.server = server;
        CreateTable.db = db;

        if ( table == '##new##' ) {
            // create table
            CreateTable.Modal( selectbox.parentNode.getElementsByTagName( 'div' )[ 0 ] );
        }
        else {
            // select table
            this.Use( table, server, db );
        }
    },
    Use: function( name, server, db ) {
        window.location = '?server=' + server + '&database=' + db + '&table=' + name;
    }
};

if ( selectbox_value( g( 'tableselect' ) ) ==  '##new##' && $_get[ 'p' ] != 'newtable' ) {
    CreateTable.server = selectbox_value( g( 'serverselect' ) );
    CreateTable.db = selectbox_value( g( 'dbselect' ) );
    CreateTable.Modal( g( 'tableselect' ).parentNode.getElementsByTagName( 'div' )[ 0 ] );
}
